Baraj constanta, august 1997
Problema 6 (La vanatoare - Mihai Oltean)
Dificultate: D2

	Doi prieteni A si B se hotarasc intr-o zi sa mearga la vanatoare de rate.
Datorita faptului ca numai A are pusca, se hotarasc sa traga alternativ. Mai mult,
pentru ca cel care trage sa nu se plictiseasca, si pentru ca nu cumva unul din
ei sa monopolizeze pusca, ei decid ca fiecare, cand ii vine randul, sa traga
maxim k gloante. Ajuns la locul de vanatoare, neindemanaticul caine al lui B
reuseste sa sperie toate ratele, care se ridica in aer formand n stoluri. In
acest moment, A (care avea pusca asupra lui) incepe sa traga. Pentru a nu pierde
timpul cu schimbarea directiei spre un alt stol, fiecare vanator va trage doar
asupra unui stol pe care il alege de fiecare data cand pusca este la celalalt.
Pana la urma, cei doi prieteni fiind vanatori foarte buni (dovada fiind si 
faptul ca fiecare glont tras a doborat cate o rata) reusesc sa omoare toate
ratele din cele n stoluri. Acum intra in actiune si trimis dupa ratele impuscate
cainele lui B (A nu are caine) care, din cauza faptului ca participa pentru prima
data la o vanatoare, s-a speriat la auzul primei impuscaturi si s-a asucns prin
tufisuri, iesind doar in momentul in care ultima rata este doborata. Limitat in
gandire (ca orice caine), acesta va crede ca vanatorul care a doborat ultima rata
le-a doborat si pe celelalte; deci ii va aduce acestuia toate ratele.
Presupunand ca sunteti A, gasiti (daca exista) o strategie de impuscare a ratelor
astfel incat sa fiti vanatorul caruia cainele ii va aduce toata prada.
	Numele fisierului de intrare este joc.in si contine mai multe seturi de
date; anume:
- pe liniile cu numar de ordine impar se afla n si k (1<=n,k<=10000);
- pe liniile cu numar de ordine par se afla numarul de pasari din fiecare din
cele n stoluri (n dat in linia precedenta); cele n numere sunt intregi pozitive.
Atentie: Toate seturile de date dintr-un fisier alcatuiesc un pachet de date de
intrare. Punctajele se acorda pe pachete, adica pentru a primi punctajul atasat
unui pachet trebuie sa rezolvati corect toate seturile de date din el.
	Pentru a va usura munca, comisia va pune la dispozitie un unit cu numele
joc.tpu care contine urmatoarele proceduri:
StartJoc - este procedura pe care trebuie sa o apelati inainte de a incepe un 
	nou joc.
DeclarStrategia(strategia:integer) - este procedura pe care o apelati pentru a-i
comunica unitului daca aveti sau nu strategie sigura de castig. Parametrul
strategia are valoarea 1 daca aveti strategie sigura de castig si 0 in caz contrar.
MutareaMea(stol,nr:longint) - este procedura pe care o apelati pentru a-i comunica
unitului stolul si numarul de pasari din acel stol pe care le doborati;
MutareaTa(var stol,nr:longint) - este procedura pe care o apelati pentru ca unitul
sa va returneze mutarea pe care o va face calculatorul;
SfarsitJoc - este procedura pe care trebuie sa o apelati la sfarsitul fiecarui joc
(set de date).
	In cazul in care nu aveti strategie sigura de castig, veti apela doar:
StartJoc;
DeclarStrategia(0);
SfarsitJoc;
	In cazul in care aveti strategie sigura de castig, jucati jocul cu unitul
dat, folosindu-va de procedurile de mai sus.
Timpul de executie pentru determinarea existentei strategiei sigure de castig este
1 secunda/test, iar pentru jucat - 5 secunde/test.
======================================
Solutia 1 (Mihai Olteanu)
program jocul;
  uses joc,crt;
  const MaxN=5000;
  var stol,s,nr,k,n,i,suma,poz:word;
      f:text;
      a:array[1..MaxN] of word;

  function final:boolean;
    var suma,i:word;
  begin
      i:=1;
      while (i<=n) and (a[i]=0) do inc(i);
      final:=i=n+1;
  end;

begin
  assign(f,'joc.in');
  reset(f);
  while not seekeof(f) do
  begin
    readln(f,n,k);
    suma:=0;
    for i:=1 to n do
      if not(seekeoln(f))
      then begin read(f,a[i]); suma:=suma xor (a[i] mod (k+1)); end;
    StartJoc;
    if suma=0
    then begin DeclarStrategia(1); SfarsitJoc; end
    else begin
           DeclarStrategia(0);
           while not final do
           begin
             suma:=0;
             for i:=1 to n do suma:=suma xor (a[i] mod (k+1));
             poz:=trunc((ln(suma)/ln(2)));
             if 1 shl (poz+1)=suma then inc(poz);
             i:=1;
             while ((1 shl poz) and (a[i] mod (k+1)))=0 do inc(i);
             s:=suma xor (a[i] mod (k+1));
             MutareaMea(i,(a[i] mod (k+1))-s); a[i]:=a[i]-(a[i] mod (k+1))+s; suma:=0;
             if not(final)
             then begin MutareaTa(stol,nr); a[stol]:=a[stol]-nr; end;
           end;
          SfarsitJoc;
        end;
  end;
  close(f);
end.
---------------------------------
Solutia 2 (Mihai Olteanu)
{$A+,B-,D+,E+,F-,G-,I+,L+,N-,O-,P-,Q+,R+,S+,T-,V+,X+}
{$M 16000,0,10000}
unit joc;

  interface
    procedure StartJoc;
    procedure MutareaMea(stol,nr:word);
    procedure MutareaTa(var stol,nr:word);
    procedure DeclarStrategia(st:integer);
    procedure SfarsitJoc;
    const Castig=0;
          Pierd=1;

  implementation
  uses dos,windos,crt;
  type intproc=procedure(flags:word);
  var regs:TRegisters;
      old8h:intproc;
      p:pointer;
      ok_:^byte;
      timp,ts,maxtimp,e:word;
      lx,ly:byte;
      int08seg,int08ofs:word;

    const MaxN=200;
    type vector=array[1..MaxN] of word;
    var f:text;
        a:vector;
        aa:array[1..3] of vector;
        i,j,nc,n,y,k:word;
        strategie_declarata:integer;
        sfarsit:boolean;
        nn,kk:array[1..3] of word;

        declar,ok:boolean;
        mutarea_ta:boolean;

  const s2d=1;  { Timp maxim StartJoc -> DeclarStrategia }
        d2s=5;  { Timp maxim DeclarStategia -> SfarsitJoc }
        s2s=1;  { Timp maxim SfarsitJoc -> StartJoc , Inceput -> StartJoc }
        frez:string='C:\BARAJ\JOC\DATE\REZULTAT.TXT'; { Fisierul cu rezultate }

procedure new8h(flags:word);interrupt;
 begin
{  old8h(flags);}
  asm
   mov al,20h
   out 20h,al
  end;
  inc(timp);
  if ok_^=0 then
   begin
    lx:=wherex; ly:=wherey;
    ts:=timp*11 div 200;
    textcolor(green);
    gotoxy(74,1);write( ts:3,':',((timp-(ts*200 div 11))*55)mod 1000);
    textcolor(lightgray);
    gotoxy(lx,ly);
    if timp>maxtimp then
     begin
      regs.ax:=$4c00;
      msdos(regs);
     end;
   end;
end;

    function final:boolean;
      var suma,i:word;
    begin
      i:=1;
      while (i<=n) and (a[i]=0) do inc(i);
      final:=i=n+1;
    end;

    procedure Evaluare;
     begin
      writeln('[] Pachetul a fost rezolvat corect !');
      setintvec(8,p);
      assign(f,frez);
      append(f);
      writeln(f,12345);
      close(f);
     end;

    procedure StartJoc;
     begin
      declar:=false;
      mutarea_ta:=true;
      maxtimp:=s2d;
      maxtimp:=2+maxtimp*200 div 11;
      timp:=0;
      if not sfarsit and (nc>0) then
       begin
        writeln('>>> Nu ai terminat jocul inceput !');
        halt;
       end;
      sfarsit:=false;
      strategie_declarata:=3;
      nc:=nc+1;
      if nc>y then Evaluare;
      writeln('Start joc ',nc);
      a:=aa[nc];
      n:=nn[nc];
      k:=kk[nc];
     end;

    procedure SfarsitJoc;
     begin
      if sfarsit then
       begin
        writeln('>>> Termini acelasi joc de mai multe ori !!!');
        halt;
       end;
      maxtimp:=s2s;
      maxtimp:=2+maxtimp*200 div 11;
      timp:=0;
      sfarsit:=true;
      if (not(final) and (strategie_declarata=Castig)) or
         (strategie_declarata>2) then
          begin
           writeln('>>> Ai terminat jocul fara a declara strategia sau a juca complet !');
           halt;
          end;
      if nc=y then Evaluare;
     end;

    procedure MutareaMea(stol,nr:word);
      var suma:word;
    begin
      if sfarsit then
       begin
        writeln('>>> Ai terminat jocul si nu mai poti face mutari !!!');
        halt;
       end;
      if not mutarea_ta then
       begin
        writeln('>>> Nu este randul tau la mutare !');
        halt;
       end;
      if (stol<1) or (stol>n) then
       begin
        writeln('>>> Stolul din care impusti nu exista !');
        halt;
       end;
      mutarea_ta:=false;
      if nr>k then
       begin
        writeln('>>> Impusti mai mult de k rate !!!');
        halt;
       end;
      if a[stol]<nr then
       begin
        writeln('>>> Impusti dintr-un stol mai multe rate decat sunt !!!');
        halt;
       end;
      a[stol]:=a[stol]-nr;
      suma:=0;
      for i:=1 to n do suma:=suma xor (a[i] mod (k+1));
      if suma<>0
      then begin
             writeln('>>> Ai gresit !!!');
             halt;
           end;
    end;

    procedure MutareaTa(var stol,nr:word);
     begin
      if sfarsit then
       begin
        writeln('>>> Ai terminat jocul si nu mai poti face mutari !!!');
        halt;
       end;
      if mutarea_ta then
       begin
        writeln('>>> Nu este randul calculatorului la mutare !');
        halt;
       end;
      mutarea_ta:=true;
      stol:=1;
      while (a[stol]=0) and (stol<=n) do inc(stol);
      if stol>n
      then begin
            writeln('>>> Ai gresit !!!');
            halt;
           end
      else begin nr:=1; dec(a[stol]); end;
    end;

    procedure DeclarStrategia;
      var suma:word;
          ok:boolean;
    begin
      if sfarsit then
       begin
        writeln('>>> Ai terminat jocul si nu mai poti declara strategia !!!');
        halt;
       end;
      if not declar then
       begin
        maxtimp:=d2s;
        maxtimp:=2+maxtimp*200 div 11;
        timp:=0;
       end;
      declar:=true;
      suma:=0;
      for i:=1 to n do suma:=suma xor (a[i] mod (k+1));
      ok:=suma<>0;
      if (ok and (st=Pierd)) or (not ok and (st=Castig)) or
         ((st<>Pierd) and (st<>Castig)) then
          begin
           writeln('>>> Strategia declarata gresita !');
           halt;
          end;
      strategie_declarata:=st;
    end;

    begin
      textcolor(lightgray);
      textbackground(black);
      regs.ah:=$34;
      msdos(regs);
      ok_:=ptr(regs.es, regs.bx);
      getintvec(8, p);
      old8h:=intproc(p);
      int08seg:=memw[0:8*4+2];
      int08ofs:=memw[0:8*4];
      asm
       mov dx,int08seg
       mov cx,int08ofs
       mov ah,0fbh
       int 21h
      end;
      maxtimp:=s2s;
      maxtimp:=2+maxtimp*200 div 11;
      timp:=0;
      setintvec(8, @new8h);

      sfarsit:=true;
      assign(f,'joc.in');
      reset(f);
      y:=0; nc:=0;
      for j:=1 to 3 do
      begin
        y:=y+1;
        readln(f,nn[y],kk[y]);
        for i:=1 to nn[y] do
          if not(seekeoln(f)) then read(f,aa[y,i]);
        readln(f);
      end;
      close(f);
end.
-----------------------------
Program joc_conc:
{$A+,B-,D+,E+,F-,G-,I+,L+,N-,O-,P-,Q+,R+,S+,T-,V+,X+}
{$M 16000,0,10000}
unit joc;

  interface
    procedure StartJoc;
    procedure MutareaMea(stol,nr:word);
    procedure MutareaTa(var stol,nr:word);
    procedure DeclarStrategia(st:integer);
    procedure SfarsitJoc;
    const Castig=0;
          Pierd=1;

  implementation
  uses dos,windos,crt;
  type intproc=procedure(flags:word);
  var regs:TRegisters;
      old8h:intproc;
      p:pointer;
      ok_:^byte;
      timp,ts,maxtimp,e:word;
      lx,ly:byte;
      int08seg,int08ofs:word;

    const MaxN=200;
    type vector=array[1..MaxN] of word;
    var f:text;
        a:vector;
        aa:array[1..3] of vector;
        i,j,nc,n,y,k:word;
        strategie_declarata:integer;
        sfarsit:boolean;
        nn,kk:array[1..3] of word;

        declar,ok:boolean;
        mutarea_ta:boolean;

  const s2d=1;  { Timp maxim StartJoc -> DeclarStrategia }
        d2s=5;  { Timp maxim DeclarStategia -> SfarsitJoc }
        s2s=1;  { Timp maxim SfarsitJoc -> StartJoc , Inceput -> StartJoc }
{        frez:string='C:\BARAJ\JOC\DATE\REZULTAT.TXT'; { Fisierul cu rezultate }

procedure new8h(flags:word);interrupt;
 begin
{  old8h(flags);}
  asm
   mov al,20h
   out 20h,al
  end;
  inc(timp);
  if ok_^=0 then
   begin
    lx:=wherex; ly:=wherey;
    ts:=timp*11 div 200;
    textcolor(green);
    gotoxy(74,1);write( ts:3,':',((timp-(ts*200 div 11))*55)mod 1000);
    textcolor(lightgray);
    gotoxy(lx,ly);
    if timp>maxtimp then
     begin
      regs.ax:=$4c00;
      msdos(regs);
     end;
   end;
end;

    function final:boolean;
      var suma,i:word;
    begin
      i:=1;
      while (i<=n) and (a[i]=0) do inc(i);
      final:=i=n+1;
    end;

    procedure Evaluare;
     begin
      writeln('[] Pachetul a fost rezolvat corect !');
{      setintvec(8,p);
       assign(f,frez);
      append(f);
      writeln(f,12345);
      close(f);}
     end;

    procedure StartJoc;
     begin
      declar:=false;
      mutarea_ta:=true;
      maxtimp:=s2d;
      maxtimp:=2+maxtimp*200 div 11;
      timp:=0;
      if not sfarsit and (nc>0) then
       begin
        writeln('>>> Nu ai terminat jocul inceput !');
        halt;
       end;
      sfarsit:=false;
      strategie_declarata:=3;
      nc:=nc+1;
      if nc>y then Evaluare;
      writeln('Start joc ',nc);
      a:=aa[nc];
      n:=nn[nc];
      k:=kk[nc];
     end;

    procedure SfarsitJoc;
     begin
      if sfarsit then
       begin
        writeln('>>> Termini acelasi joc de mai multe ori !!!');
        halt;
       end;
      maxtimp:=s2s;
      maxtimp:=2+maxtimp*200 div 11;
      timp:=0;
      sfarsit:=true;
      if (not(final) and (strategie_declarata=Castig)) or
         (strategie_declarata>2) then
          begin
           writeln('>>> Ai terminat jocul fara a declara strategia sau a juca complet !');
           halt;
          end;
      if nc=y then Evaluare;
     end;

    procedure MutareaMea(stol,nr:word);
      var suma:word;
    begin
      if sfarsit then
       begin
        writeln('>>> Ai terminat jocul si nu mai poti face mutari !!!');
        halt;
       end;
      if not mutarea_ta then
       begin
        writeln('>>> Nu este randul tau la mutare !');
        halt;
       end;
      if (stol<1) or (stol>n) then
       begin
        writeln('>>> Stolul din care impusti nu exista !');
        halt;
       end;
      mutarea_ta:=false;
      if nr>k then
       begin
        writeln('>>> Impusti mai mult de k rate !!!');
        halt;
       end;
      if a[stol]<nr then
       begin
        writeln('>>> Impusti dintr-un stol mai multe rate decat sunt !!!');
        halt;
       end;
      a[stol]:=a[stol]-nr;
      suma:=0;
      for i:=1 to n do suma:=suma xor (a[i] mod (k+1));
      if suma<>0
      then begin
             writeln('>>> Ai gresit !!!');
             halt;
           end;
    end;

    procedure MutareaTa(var stol,nr:word);
     begin
      if sfarsit then
       begin
        writeln('>>> Ai terminat jocul si nu mai poti face mutari !!!');
        halt;
       end;
      if mutarea_ta then
       begin
        writeln('>>> Nu este randul calculatorului la mutare !');
        halt;
       end;
      mutarea_ta:=true;
      stol:=1;
      while (a[stol]=0) and (stol<=n) do inc(stol);
      if stol>n
      then begin
            writeln('>>> Ai gresit !!!');
            halt;
           end
      else begin nr:=1; dec(a[stol]); end;
    end;

    procedure DeclarStrategia;
      var suma:word;
          ok:boolean;
    begin
      if sfarsit then
       begin
        writeln('>>> Ai terminat jocul si nu mai poti declara strategia !!!');
        halt;
       end;
      if not declar then
       begin
        maxtimp:=d2s;
        maxtimp:=2+maxtimp*200 div 11;
        timp:=0;
       end;
      declar:=true;
      suma:=0;
      for i:=1 to n do suma:=suma xor (a[i] mod (k+1));
      ok:=suma<>0;
      if (ok and (st=Pierd)) or (not ok and (st=Castig)) or
         ((st<>Pierd) and (st<>Castig)) then
          begin
           writeln('>>> Strategia declarata gresita !');
           halt;
          end;
      strategie_declarata:=st;
    end;

    begin
      textcolor(lightgray);
      textbackground(black);
{      regs.ah:=$34;
      msdos(regs);
      ok_:=ptr(regs.es, regs.bx);
      getintvec(8, p);
      old8h:=intproc(p);
      int08seg:=memw[0:8*4+2];
      int08ofs:=memw[0:8*4];
      asm
       mov dx,int08seg
       mov cx,int08ofs
       mov ah,0fbh
       int 21h
      end;                   }
      maxtimp:=s2s;
      maxtimp:=2+maxtimp*200 div 11;
      timp:=0;
{      setintvec(8, @new8h);   }

      sfarsit:=true;
      assign(f,'joc.in');
      reset(f);
      y:=0; nc:=0;
      for j:=1 to 3 do
      begin
        y:=y+1;
        readln(f,nn[y],kk[y]);
        for i:=1 to nn[y] do
          if not(seekeoln(f)) then read(f,aa[y,i]);
        readln(f);
      end;
      close(f);
end.
===============================
	TESTE INTRARE
test 1:
1 10
1
1 1
3
2 100
2 2
------------------------------
test 2:
4 8
2 2 4 7
3 4
1 2 3
2 2
1 1
----------------------------
test 3:
3 4
6 7 8
3 4
6 11 8
3 4
6 11 16
--------------------------
test 4:
5 1
1 2 3 4 5
10 1
1 2 3 4 5 6 7 8 9 10
15 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
------------------------------
test 5:
100 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100 1
2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100 2
2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
---------------------------------
test 6:
100 10
1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10
100 11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
100 34
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120  101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
--------------------------------
test 7:
199 12
501 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500
200 12
500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500
200 5
2 3 5 7 8 4 1 4 6 9 12 45 32 56 43 56 78 75 42 1 2 3 5 7 8 4 1 4 6 9 12 45 32 56 43 56 78 75 42 1 2 3 5 7 8 4 1 4 6 9 12 45 32 56 43 56 78 75 42 1 2 3 5 7 8 4 1 4 6 9 12 45 32 56 43 56 78 75 42 1 2 3 5 7 8 4 1 4 6 9 12 45 32 56 43 56 78 75 42 1 2 3 5 7 8 4 1 4 6 9 12 45 32 56 43 56 78 75 42 1 2 3 5 7 8 4 1 4 6 9 12 45 32 56 43 56 78 75 42 1 2 3 5 7 8 4 1 4 6 9 12 45 32 56 43 56 78 75 42 1 2 3 5 7 8 4 1 4 6 9 12 45 32 56 43 56 78 75 42 1 2 3 5 7 8 4 1 4 6 9 12 45 32 56 43 56 78 75 42 1
------------------------------------
================================
Pogram de evaluare (Marius Vlad)
program JOC_;
uses crt;
var f:text;
    pt,i,j,k,n,m:integer;
    p:array[1..20] of integer;
    ch:char;

begin
for i:=1 to 20 do p[i]:=0;
assign(f,'C:\BARAJ\JOC\DATE\PUNCTAJ.TXT');
reset(f);
n:=0;
pt:=0;
while not seekeof(f) do
 begin
  n:=n+1;
  readln(f,p[n]);
 end;
close(f);
assign(f,'C:\BARAJ\JOC\DATE\REZULTAT.TXT');
reset(f);
i:=1;
m:=0;
readln(f,m);
while not seekeof(f) do
 begin
  readln(f,m);
  if m=12345 then
   begin
    writeln(' Test ',i,' Punctaj test ',p[i]);
    if not seekeof(f) then readln(f,m);
    pt:=pt+p[i];
   end else begin
    writeln(' Test ',i,' Punctaj test 0');
   end;
  i:=i+1;
  if (m<>11111) and (m<>12345) then
   begin
    writeln('EROARE IN FISIERUL CU REZULTATE !');
    close(f);
    halt;
   end;
 end;
if m=11111 then writeln(' Test ',i,' Punctaj test 0');
close(f);
writeln('Ai obtinut ',pt,' puncte !');
ch:=readkey;
end.
----------------------
Fisierul punctaj.txt
6
6
6
6
6
10
10
----------------------
run.bat    :
@ECHO OFF
ECHO. > C:\BARAJ\JOC\DATE\REZULTAT.TXT

ECHO  JOC - Pachetul 1 de teste
COPY C:\BARAJ\JOC\DATE\JOC.1 JOC.IN > NUL
ECHO 11111 >> C:\BARAJ\JOC\DATE\REZULTAT.TXT
C:\BARAJ\JOC\DATE\SAVE_VEC.EXE
%1
C:\BARAJ\JOC\DATE\LOAD_VEC.EXE

ECHO  JOC - Pachetul 2 de teste
COPY C:\BARAJ\JOC\DATE\JOC.2 JOC.IN > NUL
ECHO 11111 >> C:\BARAJ\JOC\DATE\REZULTAT.TXT
C:\BARAJ\JOC\DATE\SAVE_VEC.EXE
%1
C:\BARAJ\JOC\DATE\LOAD_VEC.EXE
ECHO  Evaluam rezultatele

ECHO  JOC - Pachetul 3 de teste
COPY C:\BARAJ\JOC\DATE\JOC.3 JOC.IN > NUL
ECHO 11111 >> C:\BARAJ\JOC\DATE\REZULTAT.TXT
C:\BARAJ\JOC\DATE\SAVE_VEC.EXE
%1
C:\BARAJ\JOC\DATE\LOAD_VEC.EXE

ECHO  JOC - Pachetul 4 de teste
COPY C:\BARAJ\JOC\DATE\JOC.4 JOC.IN > NUL
ECHO 11111 >> C:\BARAJ\JOC\DATE\REZULTAT.TXT
C:\BARAJ\JOC\DATE\SAVE_VEC.EXE
%1
C:\BARAJ\JOC\DATE\LOAD_VEC.EXE

ECHO  JOC - Pachetul 5 de teste
COPY C:\BARAJ\JOC\DATE\JOC.5 JOC.IN > NUL
ECHO 11111 >> C:\BARAJ\JOC\DATE\REZULTAT.TXT
C:\BARAJ\JOC\DATE\SAVE_VEC.EXE
%1
C:\BARAJ\JOC\DATE\LOAD_VEC.EXE

ECHO  JOC - Pachetul 6 de teste
COPY C:\BARAJ\JOC\DATE\JOC.6 JOC.IN > NUL
ECHO 11111 >> C:\BARAJ\JOC\DATE\REZULTAT.TXT
C:\BARAJ\JOC\DATE\SAVE_VEC.EXE
%1
C:\BARAJ\JOC\DATE\LOAD_VEC.EXE

ECHO  JOC - Pachetul 7 de teste
COPY C:\BARAJ\JOC\DATE\JOC.7 JOC.IN > NUL
ECHO 11111 >> C:\BARAJ\JOC\DATE\REZULTAT.TXT
C:\BARAJ\JOC\DATE\SAVE_VEC.EXE
%1
C:\BARAJ\JOC\DATE\LOAD_VEC.EXE

C:\BARAJ\JOC\DATE\TEVAL.EXE
ECHO  O.K.
==============================
